<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/static/bs/css/bootstrap.css">
</head>
<body>

<h3>编辑书籍</h3>


<div class="container">
    <div class="row">
        <div class="col-md-6 col-md-offset-3">
            <form action="" method="post">
                {% csrf_token %}
                <div class="form-group">
                    <label for="">名称</label>
                    <input type="text" name="title" class="form-control" value="{{ edit_book_obj.title }}">
                </div>

                <div class="form-group">
                    <label for="">价格</label>
                    <input type="text" name="price" class="form-control" value="{{ edit_book_obj.price }}">
                </div>

                <div class="form-group">
                    <label for="">出版日期</label>
                    <input type="date" name="pub_date" class="form-control"
                           value="{{ edit_book_obj.publishDate|date:'Y-m-d' }}">
                </div>

                <div class="form-group">
                    <label for="">出版社</label>
                    <select name="publish_id" id="" class="form-control">
                        {% for publish in publish_list %}
                            {% if edit_book_obj.publish == publish %}
                                <option selected value="{{ publish.pk }}">{{ publish.name }}</option>
                            {% else %}
                                <option value="{{ publish.pk }}">{{ publish.name }}</option>
                            {% endif %}
                        {% endfor %}
                    </select>
                </div>

                <div class="form-group">
                    <label for="">作者</label>
                    <select type="text" name="authors_id_list" multiple class="form-control">
                        {% for author in author_list %}
                            
                        {% if author in edit_book_obj.authors.all %}
                            <option selected value="{{ author.pk }}">{{ author.name }}</option>
                        {% else %}
                             <option value="{{ author.pk }}">{{ author.name }}</option>
                        {% endif %}

                        {% endfor %}
                    </select>
                </div>
                <input type="submit" class="btn btn-default">

            </form>
        </div>
    </div>
</div>


</body>
</html>